package com.hp.tiger.chapter11;

/**
 * @author XavierDong
 **/
public final class ActionContext {


    private static final ThreadLocal<Context> THREAD_LOCAL = new ThreadLocal<Context>() {
        @Override
        protected Context initialValue() {
            this.remove();
            return new Context();
        }
    };


    private static class ContextHolder {
        private static final ActionContext ACTION_CONTEXT = new ActionContext();
    }

    public static ActionContext getActionContext() {
        return ContextHolder.ACTION_CONTEXT;
    }


    public Context getContext() {
        return THREAD_LOCAL.get();
    }

}
